//package com.yhc.server.config;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
//import com.baomidou.mybatisplus.core.config.GlobalConfig;
//import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
//import com.taobao.txc.datasource.cobar.TxcDataSource;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//
//@Configuration
//public class DataSourceConfig {
//
//    @Autowired
//    MapperObjectHandler objectHandler;
//
//    @Bean
//    @Primary
//    @ConfigurationProperties(prefix = "spring.datasource")
//    public DruidDataSource dataSource() {
//        return DruidDataSourceBuilder.create().build();
//    }
//
//    @Bean("dataSourceProxy")
//    public TxcDataSource dataSourceProxy(DruidDataSource dataSource) {
//        return new TxcDataSource(dataSource);
//    }
//
//    @Bean
//    public GlobalConfig globalConfig(){
//        GlobalConfig globalConfig = new GlobalConfig();
//        globalConfig.setMetaObjectHandler(new MapperObjectHandler());
//        return globalConfig;
//    }
//
//    @Bean
//    public MybatisSqlSessionFactoryBean sqlSessionFactory(TxcDataSource dataSource) throws Exception {
//        MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
//        bean.setDataSource(dataSource);
////        bean.setTypeAliasesPackage("com.nft.video.server.entity");
////        bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/*.xml"));
//
//        GlobalConfig globalConfig = new GlobalConfig();
//        globalConfig.setMetaObjectHandler(objectHandler);
//        bean.setGlobalConfig(globalConfig);
//
//        return bean;
//    }
//
//    @Bean
//    public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) throws Exception {
//        return new SqlSessionTemplate(sqlSessionFactory);
//    }
//}
